package SGEngine

func CheckErr(err interface{}) {
	if err != nil {
		panic(err)
	}
}

func Sort(SortArr []interface{}, p, r int) {

	if p < r {
		q := Partion(SortArr, p, r)
		Sort(SortArr, p, q-1)
		Sort(SortArr, q+1, r)
	}
}

func Partion(a []interface{}, p, r int) int {
	x := a[r].(INode).GetTransfrom().GetMat()[14]
	middle := p
	for j := p; j < r; j++ {
		if a[j].(INode).GetTransfrom().GetMat()[14] < x {
			temp := a[middle]
			a[middle] = a[j]
			a[j] = temp
			middle++
		}
	}
	temp := a[r]
	a[r] = a[middle]
	a[middle] = temp
	return middle
}
